package com.q.qpicturebackend.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.q.qpicturebackend.model.dto.picture.*;
import com.q.qpicturebackend.model.entity.Picture;
import com.baomidou.mybatisplus.extension.service.IService;
import com.q.qpicturebackend.model.entity.User;
import com.q.qpicturebackend.model.vo.PictureVO;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;

/**
 * @author 陈奕岐
 * @description 针对表【picture(图片)】的数据库操作Service
 * @createDate 2025-05-19 14:16:56
 */
public interface PictureService extends IService<Picture> {

    /**
     * 上传图片
     *
     * @param inputSource
     * @param pictureUploadRequest
     * @param loginUser
     * @return
     */
    PictureVO uploadPicture(Object inputSource,
                            PictureUploadDTO pictureUploadRequest,
                            User loginUser);

    /**
     * 获取查询对象
     *
     * @param pictureQueryRequest
     * @return
     */
    public QueryWrapper<Picture> getQueryWrapper(PictureQueryDTO pictureQueryRequest);

    /**
     * 单条获取图片封装类
     *
     * @param picture
     * @param request
     * @return
     */
    PictureVO getPictureVO(Picture picture, HttpServletRequest request);

    /**
     * 分页获取图片封装类（多条）
     *
     * @param picturePage
     * @param request
     * @return
     */
    Page<PictureVO> getPictureVOPage(Page<Picture> picturePage, HttpServletRequest request);

    /**
     * 数据校验
     *
     * @param picture
     */
    void validPicture(Picture picture);

    /**
     * 图片审核
     *
     * @param pictureReviewDTO
     * @param loginUser
     */
    void pictureReview(PictureReviewDTO pictureReviewDTO, User loginUser);

    void fillReviewParams(Picture picture, User loginUser);

    /**
     * 头像上传
     * @param multipartFile
     * @param loginUser
     * @return
     */
    String uploadAvatar(MultipartFile multipartFile, User loginUser);

    /**
     * 批量抓取和创建图片
     *
     * @param pictureUploadByBatchRequest
     * @param loginUser
     * @return 成功创建的图片数
     */
    Integer uploadPictureByBatch(
            PictureUploadByBatchRequestDTO pictureUploadByBatchRequest,
            User loginUser
    );

    /**
     * 清理图片文件
     *
     * @param oldPicture
     */
    void clearPictureFile(Picture oldPicture);

    void checkPictureAuth(User loginUser, Picture picture);

    void deletePicture(long pictureId, User loginUser);

    void editPicture(PictureEditDTO pictureEditRequest, User loginUser);
}
